/**
 * 
 */
package net.cloudcodex.client.character.view;

import net.cloudcodex.client.campaign.view.CampaignsView;
import net.cloudcodex.client.campaign.view.CampaignsView.Message;
import net.cloudcodex.client.character.view.panel.CharacterInfosPanel;

import com.google.gwt.event.dom.client.HasClickHandlers;
import com.google.gwt.user.client.ui.Button;
import com.google.gwt.user.client.ui.DecoratedPopupPanel;
import com.google.gwt.user.client.ui.FlowPanel;
import com.google.gwt.user.client.ui.HorizontalPanel;
import com.google.inject.Inject;

/**
 * @author Daniel
 * 
 */
public class CharacterNPCCreationViewImpl extends DecoratedPopupPanel implements
		CharacterNPCCreationView {

	private CharacterInfosPanel characterInfosPanel = new CharacterInfosPanel();
	private Button addButton = new Button();
	private Button cancelButton = new Button();
	FlowPanel innerPanel = new FlowPanel();
	private Message message;

	/**
	 * 
	 */
	@Inject
	public CharacterNPCCreationViewImpl(Message message) {
		super(false, true);
		this.setGlassEnabled(true);
		this.message = message;
		this.add(innerPanel);
	}

	@Override
	public void initView() {
		characterInfosPanel.setMessage(message);
		characterInfosPanel.initComponent();
		HorizontalPanel buttonsPanel = new HorizontalPanel();
		addButton.setText(message.getCreateButton());
		cancelButton.setText(message.getCancelButton());
		buttonsPanel.add(addButton);
		buttonsPanel.add(cancelButton);
		innerPanel.add(characterInfosPanel);
		innerPanel.add(buttonsPanel);
	}

	@Override
	public HasClickHandlers getCreateButton() {
		return addButton;
	}

	@Override
	public HasClickHandlers getCancelButton() {
		return cancelButton;
	}

	@Override
	public void showPopup() {
		this.center();
	}

	@Override
	public void hidePopup() {
		this.hide();
	}

	@Override
	public void clearView() {
		characterInfosPanel.clearView();
	}

	@Override
	public String getName() {
		return characterInfosPanel.getCharacterName();
	}

	@Override
	public String getIcon() {
		return characterInfosPanel.getCharacterIcon();
	}

	@Override
	public String getDescription() {
		return characterInfosPanel.getDescription();
	}
}
